package com.handinfo.android.ui.window;

import java.io.DataInputStream;
import java.io.IOException;

import org.apache.commons.logging.Log;

import android.graphics.Bitmap;

import com.handinfo.android.DWGameManager;
import com.handinfo.android.core.graphics.DWFont;
import com.handinfo.android.core.object.Actor;
import com.handinfo.android.core.object.Animation;
import com.handinfo.android.game.Achievement;
import com.handinfo.android.game.IconManger;
import com.handinfo.android.game.Login;
import com.handinfo.android.ui.AssActivity;
import com.handinfo.android.ui.AssEveryday;
import com.handinfo.android.ui.AssOperate;
import com.handinfo.android.ui.IUIWindows;
import com.handinfo.android.ui.UIWindows;
import com.handinfo.android.uicontrols.DWControlTools;
import com.handinfo.android.uicontrols.DWControlsManager;
import com.handinfo.android.uicontrols.DWGuideAttention;
import com.handinfo.android.uicontrols.DWListener;
import com.handinfo.android.uicontrols.controls.DWAnimationBox;
import com.handinfo.android.uicontrols.controls.DWBackground;
import com.handinfo.android.uicontrols.controls.DWButton;
import com.handinfo.android.uicontrols.controls.DWFrame;
import com.handinfo.android.uicontrols.controls.DWImageBox;
import com.handinfo.android.uicontrols.controls.DWInputBox;
import com.handinfo.android.uicontrols.controls.DWLabel;
import com.handinfo.android.uicontrols.controls.DWListSubItem;
import com.handinfo.android.uicontrols.controls.DWListbox;
import com.handinfo.android.uicontrols.controls.DWMessageBox;
import com.handinfo.android.uicontrols.controls.DWPercentBar;
import com.handinfo.android.uicontrols.controls.DWTabControl;
import com.handinfo.android.uicontrols.controls.DWTabPage;
import com.handinfo.android.uicontrols.controls.DWTextbox;
import com.handinfo.android.uicontrols.controls.DWTitle;
import com.handinfo.android.utils.Tools;

public class UIAssistant implements IUIWindows
{

	Bitmap m_cr_xxbj = null;
	Bitmap m_cr_but = null;
	Bitmap m_cr_anxia = null;
	Bitmap m_cr_tit = null;
	Bitmap m_cr_tp_1 = null;
	Bitmap m_cr_tp_2 = null;
	Bitmap m_cr_grid = null;
	Bitmap m_cr_tuichu = null;
	Bitmap m_cr_but_richang = null;
	Bitmap m_cr_but_richang_anxia = null;
	DWBackground m_xbj;
	DWFrame m_assistant_frame;
	DWTitle m_ass_tit;
	DWImageBox m_ass_tit_ima;
	DWTabControl m_tabcontrol;
	DWTabPage m_tp[];
	DWBackground m_xxbj_bg[];// /小小背景
	DWListbox m_listbox_0;
	DWListbox m_listbox_1;
	DWListbox m_listbox_2;
	DWTextbox m_text_richang;
	DWTextbox m_text_yunying;
	DWButton m_but_richang;
	DWButton m_but_yunying;
	String m_tp_name[] = new String[] { "日常行为", "定时活动", "运营活动" };
	DWImageBox m_tubiao_ima_2; // /图标应该存放的图片
	int m_size1 = 1; // /第一个标签下的活动的长度
	int m_size2 = 1;// /第二个标签下的活动的长度
	int m_size3 = 1;// /第三个标签下的活动的长度
	DWButton m_but[];
	DWTextbox m_textbox[];
	DWLabel m_data_text[];
	DWImageBox m_tuichu_ima;
	DWListSubItem m_lsi;
	DWBackground m_zuo_richang_bg;
	DWBackground m_you_richang_bg;
	DWBackground m_zuo_yunying_bg;
	DWBackground m_you_yunying_bg;
	DWButton m_add_count = null;

	/**
	 * 日常定时活动、运营活动相关变量
	 */
	public byte m_assistant_type_0 = 0; //日常活动的类型
	public short m_assistant_icon_0 = 0; //-1代表日常活动闪烁，-2代表日常活动不闪烁
	public byte m_assistant_index_0 = 0; //日常活动的下标
	public byte m_assistant_type_1 = 0; // 日常活动的图标类型
	public byte m_assistant_type_2 = 0;// 定时、运营活动的图标类型
	public short m_assistant_icon_1; //定时活动的icon
	public short m_assistant_icon_2; //运营活动的icon
	public byte m_assistant_index_1; //定时活动的开启下标
	public byte m_assistant_index_2; //运营活动的开启下标
	boolean m_yunying_flag = true; //判断定时运营活动的按钮是否被按下
	public short m_instead_icon = 0; //当定时和运营活动都开启时=两个活动时间相碰时，判断后面的icon是定时的还是运营的中间转值
	public boolean m_icon_flag_1 = false;//判断定时活动是否在开启时间段内，以及是否点击过,0时是false
	public boolean m_icon_flag_2 = false;//判断运营活动是否在开启时间段内，以及是否点击过,0时是false

	////*************************************************************************************************////////
	public void Assistant()
	{
		if (m_assistant_frame != null && DWControlsManager.getInstance().contains(m_assistant_frame)) {
			DWControlsManager.getInstance().removeControl(m_assistant_frame);
		}
		m_assistant_frame = new DWFrame(DWFrame.FRAME_TYPE_FULL, true);
		m_assistant_frame.setClickClose(false);
		DWControlsManager.getInstance().addControl(m_assistant_frame);

		m_ass_tit = new DWTitle("", m_assistant_frame);
		m_ass_tit_ima = new DWImageBox(m_cr_tit);
		m_ass_tit_ima.setNearAnchor(m_ass_tit, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_assistant_frame.addControl(m_ass_tit);
		m_assistant_frame.addControl(m_ass_tit_ima);

		m_tuichu_ima = new DWImageBox(m_cr_tuichu);
		m_tuichu_ima.setNearAnchor(m_ass_tit, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, 0, 0);
		m_tuichu_ima.setTouchZoomIn(30, 30);
		m_assistant_frame.addControl(m_tuichu_ima);
		m_tuichu_ima.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				DWControlsManager.getInstance().removeControl(m_assistant_frame);
			}
		});

		m_xbj = new DWBackground(m_assistant_frame.getShowWidth() - 30, m_assistant_frame.getShowHeight() - 15
				- m_cr_tp_2.getHeight() - (m_ass_tit.getShowHeight() - 20));
		m_xbj.setNearAnchor(m_assistant_frame, Tools.LEFT_TOP, Tools.LEFT_TOP, 15, (m_ass_tit.getShowHeight() - 20)
				+ m_cr_tp_2.getHeight());
		m_assistant_frame.addControl(m_xbj);

		m_tabcontrol = new DWTabControl(m_cr_tp_1, m_cr_tp_2, m_xbj.getShowWidth() - 20, m_xbj.getShowHeight()
				+ m_cr_tp_2.getHeight());
		m_tabcontrol.setNearAnchor(m_xbj, Tools.LEFT_TOP, Tools.LEFT_TOP, 10, -m_cr_tp_2.getHeight());
		m_assistant_frame.addControl(m_tabcontrol);
		m_tabcontrol.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (m_bar_jindu != null) {
					m_assistant_frame.removeControl(m_bar_jindu);
				}
				if (m_baoxiang_num != 0) {
					for (int i = 0; i < m_baoxiang_num; i++) {
						if (m_bar_baoxiang != null && m_bar_baoxiang[i] != null) {
							m_assistant_frame.removeControl(m_bar_baoxiang[i]);
						}
						if (m_bar_donghua != null && m_bar_donghua[i] != null) {
							m_assistant_frame.removeControl(m_bar_donghua[i]);
							m_assistant_frame.removeControl(m_touch_donghua[i]);
						}
					}
				}
				if (m_tabcontrol.getPageIndex() == 0)
				{
					///日常行为

					DWGameManager.getInstance().getSendMessage().sendAssistantEverydayOpen();
				}
				else if (m_tabcontrol.getPageIndex() == 1) {
					// /定时活动
					DWGameManager.getInstance().getSendMessage().sendAssistantActivityOpen();
				}
				else if (m_tabcontrol.getPageIndex() == 2) {
					// /运营活动
					DWGameManager.getInstance().getSendMessage().sendAssistantOperateOpen();
				}
			}
		});
		m_tp = new DWTabPage[3];
		for (int m_tp_index = 0; m_tp_index < m_tp_name.length; m_tp_index++) {
			m_tp[m_tp_index] = new DWTabPage();
			m_tp[m_tp_index].setName(m_tp_name[m_tp_index]);
			if (m_tp_index == 0) {

				//listBox
				m_listbox_0 = new DWListbox(m_tabcontrol.getShowWidth() - DWGameManager.Screen_Width * 3 / 128,
						m_tabcontrol.getShowHeight() * 2 / 3);//需要计算
				m_listbox_0.setNearAnchor(m_tp[m_tp_index], Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0, 0);
				m_listbox_0.setShowBackgroundRect(false);
				m_listbox_0.setLineSpacing(10);
				m_tp[m_tp_index].addControls(m_listbox_0);

			}
			else if (m_tp_index == 1) {
				m_listbox_1 = new DWListbox(m_tabcontrol.getShowWidth() - 30, m_tabcontrol.getShowHeight()
						- m_cr_tp_2.getHeight() - 5 - m_cr_but_richang.getHeight() - 10);
				m_listbox_1.setNearAnchor(m_tp[m_tp_index], Tools.LEFT_TOP, Tools.LEFT_TOP, 15, 5);
				m_listbox_1.setLineSpacing(10);
				m_listbox_1.setShowBackgroundRect(false);

				m_add_count = new DWButton("竞技增次", m_cr_but_richang);
				m_add_count.setDownImage(m_cr_but_richang_anxia);
				m_add_count.setShow(false);
				m_add_count.setTouch(false);
				m_add_count.setNearAnchor(m_listbox_1, Tools.RIGHT_TOP, Tools.RIGHT_BOTTOM, 0, 5);
				m_add_count.addListener(new DWListener() {

					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						DWGameManager.getInstance().getSendMessage().sendAddCount();
					}
				});
				m_tp[m_tp_index].addControls(m_listbox_1);
				m_tp[m_tp_index].addControls(m_add_count);
			}
			else if (m_tp_index == 2) {
				m_zuo_yunying_bg = new DWBackground(m_cr_xxbj, (m_tabcontrol.getShowWidth() - 20) / 3, m_tabcontrol
						.getShowHeight()
						- m_cr_tp_2.getHeight() - 10);
				m_zuo_yunying_bg.setNearAnchor(m_tp[m_tp_index], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				m_tp[m_tp_index].addControls(m_zuo_yunying_bg);

				m_listbox_2 = new DWListbox(m_zuo_yunying_bg.getShowWidth() - 10, m_zuo_yunying_bg.getShowHeight() - 10);
				m_listbox_2.setNearAnchor(m_zuo_yunying_bg, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
				m_listbox_2.setLineSpacing(10);
				m_tp[m_tp_index].addControls(m_listbox_2);

				m_you_yunying_bg = new DWBackground(m_cr_xxbj, m_tabcontrol.getShowWidth() - 20
						- m_zuo_yunying_bg.getShowWidth(), m_zuo_yunying_bg.getShowHeight()
						- m_cr_but_richang.getHeight() - 5);
				m_you_yunying_bg.setNearAnchor(m_zuo_yunying_bg, Tools.LEFT_TOP, Tools.RIGHT_TOP, 20, 0);
				m_tp[m_tp_index].addControls(m_you_yunying_bg);

				m_text_yunying = new DWTextbox("", m_you_yunying_bg.getShowWidth() - 20, m_you_yunying_bg
						.getShowHeight() - 20);
				m_text_yunying.setNearAnchor(m_you_yunying_bg, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
				m_tp[m_tp_index].addControls(m_text_yunying);

				m_but_yunying = new DWButton("参与", m_cr_but_richang);
				m_but_yunying.setDownImage(m_cr_but_richang_anxia);
				m_but_yunying.setNearAnchor(m_you_yunying_bg, Tools.RIGHT_TOP, Tools.RIGHT_BOTTOM, -10, 5);
				m_but_yunying.setShow(false);
				m_but_yunying.setTouch(false);
				m_but_yunying.addListener(new DWListener() {

					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						if (m_operate_list != null) {
							if (m_operate_list[m_listbox_2.getTouchIndex()].m_funcType == 0) {
								DWGuideAttention.openInterface(
										m_operate_list[m_listbox_2.getTouchIndex()].m_parameter[0],
										m_operate_list[m_listbox_2.getTouchIndex()].m_parameter[1]);
								DWControlsManager.getInstance().removeControl(m_assistant_frame);
								Tools.debugPrintln("打开界面");
							}
							else if (m_operate_list[m_listbox_2.getTouchIndex()].m_funcType == 1) {
								DWGameManager.getInstance().getSendMessage().sendScenePathfinding(
										m_operate_list[m_listbox_2.getTouchIndex()].m_parameter[0]);
								DWControlsManager.getInstance().removeControl(m_assistant_frame);
								Tools.debugPrintln("寻路");
							}
							else if (m_operate_list[m_listbox_2.getTouchIndex()].m_funcType == 2
									|| m_operate_list[m_listbox_2.getTouchIndex()].m_funcType == 3) {
								DWGameManager
										.getInstance()
										.getSendMessage()
										.sendAssistantOperateSend(
												m_operate_list[m_listbox_2.getTouchIndex()].m_key,
												m_operate_list[m_listbox_2.getTouchIndex()].m_funcType,
												m_operate_list[m_listbox_2.getTouchIndex()].m_parameter[0]);
								DWControlsManager.getInstance().removeControl(m_assistant_frame);
								Tools.debugPrintln("排队参加");
							}
						}
					}
				});
				m_tp[m_tp_index].addControls(m_but_yunying);
			}
			m_tabcontrol.addTabPage(m_tp[m_tp_index]);
		}
	}

	/**
	 * 刷新 日常行为的listbox
	 */
	private DWImageBox[] m_richang_beijing;//背景图
	private DWTextbox[] m_richang_title;//名字及进度
	private DWTextbox[] m_richang_jiangli;//奖励
	private DWButton[] m_richang_aniu;//领取按钮
	private DWImageBox[] m_richang_zhuangtai;//状态
	private Bitmap m_bm_ming = null;
	private Bitmap m_bm_an = null;
	private Bitmap m_bm_wancheng = null;
	private Bitmap m_bm_weiwancheng = null;
	private int m_dianji_index = 0;
	private int m_baoxiang_index = 0;

	private void refreshListBox()
	{
		if (m_listbox_0 == null || m_richang_size == 0) {
			return;
		}
		m_listbox_0.removeAllSubItem();
		if (m_subitem != null) {
			m_subitem = null;
			m_richang_beijing = null;
			m_richang_title = null;
			m_richang_jiangli = null;
			m_richang_aniu = null;
			m_richang_zhuangtai = null;
		}
		m_subitem = new DWListSubItem[m_richang_size];//listbox的subitem项
		m_richang_beijing = new DWImageBox[m_richang_size];//没个日常的小背景
		m_richang_title = new DWTextbox[m_richang_size];
		m_richang_jiangli = new DWTextbox[m_richang_size];
		m_richang_aniu = new DWButton[m_richang_size];
		m_richang_zhuangtai = new DWImageBox[m_richang_size];

		for (int i = 0; i < m_richang_size; i++) {
			final int index = i;
			m_subitem[i] = new DWListSubItem();

			m_richang_beijing[i] = new DWImageBox(m_cr_xxbj);
			m_richang_beijing[i].setShowWideHigh(m_listbox_0.getShowWidth() / 2 - DWGameManager.Screen_Width / 128,
					m_listbox_0.getShowHeight() / 2 - DWGameManager.Screen_Height / 72);//需要计算
			if (i % 2 == 0) {//左侧
				//小背景	
				m_richang_beijing[i].setNearAnchor(m_subitem[i / 2], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				refreshIcon(i);
				m_subitem[i / 2].addControls(m_richang_beijing[i]);
				m_subitem[i / 2].addControls(m_richang_title[i]);
				m_subitem[i / 2].addControls(m_richang_jiangli[i]);
				if (m_everyday_list[i].m_state == 0 || m_everyday_list[i].m_state == 2) {//参与或者领奖
					m_subitem[i / 2].addControls(m_richang_aniu[i]);
				}
				else {//
					m_subitem[i / 2].addControls(m_richang_zhuangtai[i]);
				}
				m_listbox_0.addSubItem(m_subitem[i / 2]);
			}
			else {//右侧
				m_richang_beijing[i].setNearAnchor(m_subitem[i - i / 2 - i % 2], Tools.LEFT_TOP, Tools.LEFT_TOP,
						m_listbox_0.getShowWidth() / 2 + DWGameManager.Screen_Width / 128, 0);
				refreshIcon(i);
				m_subitem[i - i / 2 - i % 2].addControls(m_richang_beijing[i]);
				m_subitem[i - i / 2 - i % 2].addControls(m_richang_title[i]);
				m_subitem[i - i / 2 - i % 2].addControls(m_richang_jiangli[i]);
				if (m_everyday_list[i].m_state == 0 || m_everyday_list[i].m_state == 2) {//参与或者领奖
					m_subitem[i - i / 2 - i % 2].addControls(m_richang_aniu[i]);
				}
				else {//
					m_subitem[i - i / 2 - i % 2].addControls(m_richang_zhuangtai[i]);
				}
			}
			m_richang_aniu[index].addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					if (m_everyday_list != null)
					{
						if (m_everyday_list[index].m_state == 0) {
							if (m_everyday_list[index].m_type == 0)
							{
								DWGuideAttention.openInterface(m_everyday_list[index].m_type_key,
										m_everyday_list[index].m_type_subkey);
								Tools.debugPrintln("打开界面");
							}
							else if (m_everyday_list[index].m_type == 1)
							{
								DWGameManager.getInstance().getSendMessage().sendScenePathfinding(
										m_everyday_list[index].m_type_key);
								Tools.debugPrintln("寻路");
							}
							DWControlsManager.getInstance().removeControl(m_assistant_frame);
						}
						else {//状态2 领取
							m_dianji_index = index;
							DWGameManager.getInstance().getSendMessage().sendGetRiChang(
									m_everyday_list[m_dianji_index].m_index, (byte) 0);//0 普通领奖1总领奖
						}

					}
				}
			});
		}
	}

	/**
	 * 日常框中的显示布局
	 */
	private void refreshIcon(int i)
	{
		//标题
		m_richang_title[i] = new DWTextbox("<mark c=FFBB11>" + " " + m_everyday_list[i].m_name
				+ m_everyday_list[i].m_plan + "</mark>");
		m_richang_title[i].setNearAnchor(m_richang_beijing[i], Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0,
				DWGameManager.Screen_Height / 72);
		//奖励
		m_richang_jiangli[i] = new DWTextbox("奖励 : " + m_everyday_list[i].m_reward + " "
				+ m_everyday_list[i].m_huoyuedu + "点活跃度");
		m_richang_jiangli[i].setNearAnchor(m_richang_beijing[i], Tools.LEFT_TOP, Tools.LEFT_VCENTER,
				DWGameManager.Screen_Width / 128, 0);
		//按钮
		m_richang_aniu[i] = new DWButton("参与", m_bm_ming);
		m_richang_aniu[i].setDownImage(m_bm_an);
		m_richang_aniu[i].setNearAnchor(m_richang_beijing[i], Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM,
				-DWGameManager.Screen_Width / 128, -DWGameManager.Screen_Height / 72);
		//状态（与按钮一样）
		m_richang_zhuangtai[i] = new DWImageBox(m_bm_wancheng);
		m_richang_zhuangtai[i].setNearAnchor(m_richang_beijing[i], Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM,
				-DWGameManager.Screen_Width / 128, -DWGameManager.Screen_Height / 72);
		if (m_everyday_list[i].m_state == 0) {//参与
			m_richang_aniu[i].setName("参与");
		}
		else if (m_everyday_list[i].m_state == 2) {//领奖
			m_richang_aniu[i].setName("领奖");
		}
		else if (m_everyday_list[i].m_state == 3) {//完成
			m_richang_zhuangtai[i].setBackground(m_bm_wancheng, false);
		}
		else if (m_everyday_list[i].m_state == 1) {//未完成
			m_richang_zhuangtai[i].setBackground(m_bm_weiwancheng, false);
		}

	}

	/**
	 * 进度条区域
	 */
	private DWTextbox m_bar_huoyue = null;
	private DWImageBox m_bar_tu = null;
	private Bitmap m_bm_huoyue = null;
	private DWPercentBar m_bar_jindu = null;
	private Bitmap m_bm_foreground = null;
	private Bitmap m_bm_background = null;
	//
	private DWTextbox m_bar_jiangli = null;//进度条的奖励
	private DWTextbox m_bar_jindushu = null;//任务完成数
	private DWImageBox m_jiangli_ditu = null;
	private DWImageBox m_wanchengshu_ditu = null;
	private Bitmap m_bm_ditu = null;
	//礼包（进度条上的）
	private int m_bar_total = 0;//总值
	private int m_bar_nowNum = 0;//当前值
	private byte m_baoxiang_num = 0;//礼包个数
	private int[] m_libao_biaozhi;//标志位
	private int[] m_libao_zhi;//各个礼包位置的数值
	private byte[] m_libao_zhuangtai;//礼包的状态
	private String[] m_libao_jiangli;//礼包的奖励
	private int m_richang_count = 0;//未完成的个数

	private DWImageBox[] m_bar_baoxiang;
	private Bitmap m_baoxiang_ming = null;
	private Bitmap m_baoxiang_an = null;
	private Bitmap m_baoxiang_kai = null;
	private DWAnimationBox[] m_bar_donghua;//宝箱动画
	private DWImageBox[] m_touch_donghua;//为了修正动画触摸偏移
	private Actor m_donghua_baoxiang;

	private void refreshBar()
	{
		if (m_bar_huoyue != null) {
			m_bar_huoyue = null;
			m_bar_tu = null;
			m_bar_jindu = null;
			m_bar_jiangli = null;
			m_bar_jindushu = null;
		}
		m_bar_tu = new DWImageBox(m_bm_huoyue);
		m_bar_tu.setNearAnchor(m_listbox_0, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, DWGameManager.Screen_Width / 128,
				DWGameManager.Screen_Height / 36);

		m_bar_huoyue = new DWTextbox(m_bar_nowNum + "/" + m_bar_total);
		m_bar_huoyue.setNearAnchor(m_bar_tu, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 0, 0);

		m_bar_jindu = new DWPercentBar(DWGameManager.Screen_Width * 85 / 128, m_bm_foreground, m_bm_background);//m_listbox_0.getShowWidth() - m_bar_huoyue.getShowWidth() - 50
		m_bar_jindu.setPercent(m_bar_nowNum, m_bar_total);//变化
		m_bar_jindu.setNearAnchor(m_xbj, Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, DWGameManager.Screen_Width / 128
				+ m_bar_tu.getShowWidth() + m_bar_huoyue.getShowWidth() + DWGameManager.Screen_Width * 5 / 128,
				-m_listbox_0.getShowHeight() / 3 + DWGameManager.Screen_Height / 9);
		//进度条上的宝箱和动画
		m_bar_baoxiang = new DWImageBox[m_baoxiang_num];
		m_bar_donghua = new DWAnimationBox[m_baoxiang_num];
		m_touch_donghua = new DWImageBox[m_baoxiang_num];
//		m_libao_zhi = new int[m_baoxiang_num];
//		m_libao_zhuangtai = new byte[m_baoxiang_num];
		for (int i = 0; i < m_baoxiang_num; i++) {
			final int index = i;
			m_bar_baoxiang[i] = new DWImageBox(m_baoxiang_an);
			m_bar_baoxiang[i].setNearAnchor(m_bar_jindu, Tools.HCENTER_VCENTER, Tools.LEFT_VCENTER, m_libao_zhi[i]
					* DWGameManager.Screen_Width * 85 / 128 / m_bar_total - 20, 0);
			if (m_libao_zhuangtai[i] == 0) {//未达到
				m_bar_baoxiang[i].setBackground(m_baoxiang_an, false);
			}
			else if (m_libao_zhuangtai[i] == 1) {//已达到
				m_bar_baoxiang[i].setBackground(m_baoxiang_ming, false);
			}
			else if (m_libao_zhuangtai[i] == 2) {//已领取
				m_bar_baoxiang[i].setBackground(m_baoxiang_kai, false);
			}
			//动画
			m_bar_donghua[i] = new DWAnimationBox(m_donghua_baoxiang);
			m_bar_donghua[i].setNearAnchor(m_bar_baoxiang[i], Tools.HCENTER_BOTTOM, Tools.HCENTER_VCENTER, 0, 0);
			//触摸
			m_touch_donghua[i] = new DWImageBox(m_baoxiang_ming);
			m_touch_donghua[i].setShow(false);
			m_touch_donghua[i].setTouch(true);
			m_touch_donghua[i].setNearAnchor(m_bar_donghua[i], Tools.HCENTER_VCENTER, Tools.HCENTER_BOTTOM, 0, 0);
			m_touch_donghua[index].addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					m_baoxiang_index = index;
					DWGameManager.getInstance().getSendMessage().sendGetRiChang(m_libao_biaozhi[m_baoxiang_index],
							(byte) 1);//0 普通领奖1总领奖

				}
			});
		}

		//对应礼包
		m_bar_jiangli = new DWTextbox("");
		m_bar_jiangli.setNearAnchor(m_bar_huoyue, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0,
				DWGameManager.Screen_Height / 36);

		for (int i = 0; i < m_baoxiang_num; i++) {
			if (m_libao_zhuangtai[i] != 2) {
				m_bar_jiangli.setText("<mark c=FFBB11>宝箱</mark>" + "<mark c=FFBB11>" + (i + 1) + ":</mark>"
						+ m_libao_jiangli[i]);
				break;
			}
		}
		//宝箱奖励的底图
		m_jiangli_ditu = new DWImageBox(m_bm_ditu);
		m_jiangli_ditu.setShowWideHigh(m_bar_jiangli.getShowWidth() + DWGameManager.Screen_Width * 10 / 128,
				m_bar_jiangli.getShowHeight());
		m_jiangli_ditu.setNearAnchor(m_bar_huoyue, Tools.LEFT_TOP, Tools.LEFT_BOTTOM,
				-DWGameManager.Screen_Width * 5 / 128, DWGameManager.Screen_Height / 36);

		m_bar_jindushu = new DWTextbox("<mark c=FFBB11>今日未完成完成：</mark>" + m_richang_count + "个");
		m_bar_jindushu.setNearAnchor(m_tp[0], Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, -DWGameManager.Screen_Width / 64,
				-DWGameManager.Screen_Height / 36);
		//完成任务数的底图
		m_wanchengshu_ditu = new DWImageBox(m_bm_ditu);
		m_wanchengshu_ditu.setShowWideHigh(m_bar_jindushu.getShowWidth() + DWGameManager.Screen_Width * 10 / 128,
				m_bar_jindushu.getShowHeight());
		m_wanchengshu_ditu.setNearAnchor(m_tp[0], Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, -DWGameManager.Screen_Width
				/ 64 + DWGameManager.Screen_Width * 5 / 128, -DWGameManager.Screen_Height / 36);

		m_tp[0].addControls(m_bar_tu);
		m_tp[0].addControls(m_bar_huoyue);
		m_assistant_frame.addControl(m_bar_jindu);//加在frame中的 要注意上边切标签的时候移除
		for (int i = 0; i < m_baoxiang_num; i++) {
			m_assistant_frame.addControl(m_bar_baoxiang[i]);
		}
		for (int i = 0; i < m_baoxiang_num; i++) {
			if (m_libao_zhuangtai[i] == 1) {//已达到
				m_assistant_frame.addControl(m_bar_donghua[i]);
				m_assistant_frame.addControl(m_touch_donghua[i]);
				break;
			}
		}
		m_tp[0].addControls(m_jiangli_ditu);
		m_tp[0].addControls(m_wanchengshu_ditu);
		m_tp[0].addControls(m_bar_jiangli);
		m_tp[0].addControls(m_bar_jindushu);
	}

	/**
	 * 领奖是否成功
	 * @param dis
	 * @throws IOException
	 */
	public void recvLingjiang(DataInputStream dis) throws IOException
	{
		int index = dis.readInt();//标志位
		byte type = dis.readByte();//0 普通领奖1总领奖
		byte status = dis.readByte();//0失败 1成功
		if (type == 0) {
			if (status == 0) {
				DWGameManager.getInstance().addSystemInfo(
						DWGameManager.SYSTEM_INFO_TYPE_B, "领取失败！");
			}
			else {
//				m_richang_count = m_richang_count-1;
//				if(m_richang_count < 0){
//					m_richang_count = 0;
//				}
//				m_bar_jindushu.setText("今日未完成完成："+m_richang_count+"个");
				m_richang_zhuangtai[m_dianji_index].setBackground(m_bm_wancheng, false);
				m_subitem[m_dianji_index / 2].removeControl(m_richang_aniu[m_dianji_index]);
				m_subitem[m_dianji_index / 2].addControls(m_richang_zhuangtai[m_dianji_index]);
			}

		}
		else {
			if (status == 0) {
				DWGameManager.getInstance().addSystemInfo(
						DWGameManager.SYSTEM_INFO_TYPE_B, "领取失败！");
			}
			else {
				if (m_bar_jiangli != null) {
					m_assistant_frame.removeControl(m_bar_donghua[m_baoxiang_index]);
					m_assistant_frame.removeControl(m_touch_donghua[m_baoxiang_index]);
					if (m_baoxiang_index < (m_baoxiang_num - 1)) {
						m_bar_jiangli.setText("奖励" + m_libao_jiangli[m_baoxiang_index + 1]);
						if (m_libao_zhuangtai[m_baoxiang_index + 1] == 1) {
							m_assistant_frame.addControl(m_bar_donghua[m_baoxiang_index + 1]);
							m_assistant_frame.addControl(m_touch_donghua[m_baoxiang_index + 1]);
						}
					}
					else {
						m_bar_jiangli.setText("");
					}
					m_bar_baoxiang[m_baoxiang_index].setBackground(m_baoxiang_kai, false);
//					index =index +1;
				}
			}

		}

	}

	public DWFrame m_add_frame = null;
	public DWTitle m_tit = null;
	public DWImageBox m_tit_ima = null;
	public DWImageBox m_tc_ima = null;
	public Bitmap m_cr_tit_add = null;
	public DWImageBox m_left_ima = null;
	public DWImageBox m_right_ima = null;
	public DWButton m_add_but = null;
	public DWInputBox m_input = null;
	public DWTextbox m_must_text = null;
	public DWTextbox m_count_text = null;
	public DWImageBox m_yuanbao_ima = null;
	public Bitmap m_cr_yunbao = null;
	public Bitmap m_cr_left = null;
	public Bitmap m_cr_right = null;
	byte m_longest = 0;
	int m_gold = 0;
	int m_huilv = 0;
	byte m_tpe = 0;

	public void recvAddCount(DataInputStream dis) throws IOException
	{
		m_type = dis.readByte();
		if (m_type == 1) {
			m_longest = dis.readByte();
			m_huilv = dis.readInt();
			m_gold = ((int) m_longest) * m_huilv;
			if (m_longest > 0) {
				if (DWControlsManager.getInstance().contains(m_add_frame)) {
					if (m_input != null) {
						m_input.setText(Byte.toString(m_longest));
					}
					if (m_must_text != null) {
						m_must_text.setText("需要" + "<mark c=ffc001>" + m_gold + "</mark>");
						m_yuanbao_ima.setNearAnchor(m_must_text, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5, 0);
					}
					if (m_count_text != null) {
						if (DWGameManager.getInstance().m_role.m_vip_lv == 0) {
							m_count_text.setText("<mark c=ffc001>" + "非VIP玩家，今日还可购买" + "</mark>" + "<mark c=55FF00>"
									+ m_longest + "</mark>" + "<mark c=ffc001>" + "次" + "</mark>");
						}
						else if (DWGameManager.getInstance().m_role.m_vip_lv > 0) {
							m_count_text.setText("<mark c=ffc001>" + "VIP"
									+ DWGameManager.getInstance().m_role.m_vip_lv + "玩家，今日还可购买" + "</mark>"
									+ "<mark c=55FF00>" + m_longest + "</mark>"
									+ "<mark c=ffc001>" + "次" + "</mark>");
						}
					}
				}
				else if (!DWControlsManager.getInstance().contains(m_add_frame)) {
					AddCount();
				}
			}
			else if (m_longest == 0) {
				if (DWControlsManager.getInstance().contains(m_add_frame)) {
					if (m_input != null) {
						m_input.setText(Byte.toString(m_longest));
					}
					if (m_must_text != null) {
						m_must_text.setText("需要" + "<mark c=ffc001>" + m_gold + "</mark>");
						m_yuanbao_ima.setNearAnchor(m_must_text, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5, 0);
					}
					if (m_count_text != null) {
						if (DWGameManager.getInstance().m_role.m_vip_lv == 0) {
							m_count_text.setText("<mark c=ffc001>" + "非VIP玩家，今日还可购买" + "</mark>" + "<mark c=55FF00>"
									+ m_longest + "</mark>" + "<mark c=ffc001>" + "次" + "</mark>");
						}
						else if (DWGameManager.getInstance().m_role.m_vip_lv > 0) {
							m_count_text.setText("<mark c=ffc001>" + "VIP"
									+ DWGameManager.getInstance().m_role.m_vip_lv + "玩家，今日还可购买" + "</mark>"
									+ "<mark c=55FF00>" + m_longest + "</mark>"
									+ "<mark c=ffc001>" + "次" + "</mark>");
						}
					}
				}
				else if (!DWControlsManager.getInstance().contains(m_add_frame)) {
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "抱歉,您今日的次数已经用尽。");
				}
			}
			if (DWControlsManager.getInstance().contains(m_assistant_frame)) {
				DWGameManager.getInstance().getSendMessage().sendAssistantActivityCount();
			}
			Tools.debugPrintln("状态" + m_type);
			Tools.debugPrintln("还可购买的数量值" + m_longest);
			Tools.debugPrintln("汇率：" + m_huilv);
		}
		else {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "获取网络信息失败。");
		}
	}

	public void recvAddBuy(DataInputStream dis) throws IOException
	{
		byte m_status = dis.readByte();
		if (m_status == 0) {
			Tools.debugPrintln("状态" + m_status);
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "抱歉，购买竞技次数失败。");
		}
		else if (m_status == 1) {
			Tools.debugPrintln("状态" + m_status);
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "恭喜，成功购买个人竞技" + m_count + "次。");
			DWGameManager.getInstance().getSendMessage().sendAddCount();
		}
	}

	byte m_count = 0;

	public void AddCount()
	{
		if (DWControlsManager.getInstance().contains(m_add_frame)) {
			if (m_add_frame != null) {
				DWControlsManager.getInstance().removeControl(m_add_frame);
			}
		}
		if (DWGameManager.AdpaterType == DWGameManager.AD_HIGH) {
			m_add_frame = new DWFrame(500, 400);
		}
		else {
			m_add_frame = new DWFrame(400, 300);
		}
		m_add_frame.setClickClose(false);
		m_add_frame.setCentre();
		DWControlsManager.getInstance().addControl(m_add_frame);

		DWTitle m_tit = new DWTitle("", m_add_frame);
		DWImageBox m_tit_ima = new DWImageBox(m_cr_tit_add);
		m_tit_ima.setNearAnchor(m_tit, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);

		m_tuichu_ima = new DWImageBox(m_cr_tuichu);
		m_tuichu_ima.setNearAnchor(m_tit, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, 0, 0);
		m_tuichu_ima.setTouchZoomIn(20, 20);
		m_tuichu_ima.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				DWControlsManager.getInstance().removeControl(m_add_frame);
			}
		});

		m_xbj = new DWBackground(m_add_frame.getShowWidth() - 20, m_add_frame.getShowHeight()
				- (m_tit.getShowHeight() - 20) - 20);
		m_xbj.setFill(true);
		m_xbj.setNearAnchor(m_add_frame, Tools.LEFT_TOP, Tools.LEFT_TOP, 10, (m_tit.getShowHeight() - 20) + 10);

		DWTextbox m_tb = new DWTextbox("<mark c=55FF00>" + "增加个人竞技数量：" + "</mark>");
		m_tb.setNearAnchor(m_xbj, Tools.LEFT_TOP, Tools.LEFT_TOP, 20, 20);

		m_left_ima = new DWImageBox(m_cr_left);
		m_left_ima.setNearAnchor(m_tb, Tools.RIGHT_TOP, Tools.RIGHT_BOTTOM, 0, 15);
		m_left_ima.setTouchZoomIn(15, 20);
		m_left_ima.addListener(m_left_lis);

		m_input = new DWInputBox(m_xbj.getShowWidth() - 40 - m_tb.getShowWidth() - m_cr_right.getWidth() - 30,
				m_cr_right.getHeight() - 10, m_add_frame);
		m_input.setText(Byte.toString(m_longest));
		m_input.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (DWControlsManager.getInstance().contains(m_add_frame)) {
					if (m_must_text != null) {
						int m_gold = Integer.parseInt(m_input.getText()) * m_huilv;
						m_must_text.setText("需要" + "<mark c=ffc001>" + m_gold + "</mark>");
						m_yuanbao_ima.setNearAnchor(m_must_text, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5, 0);
					}
					if (m_count_text != null) {
						if (DWGameManager.getInstance().m_role.m_vip_lv == 0) {
							m_count_text.setText("<mark c=ffc001>" + "非VIP玩家，今日还可购买" + "</mark>" + "<mark c=55FF00>"
									+ m_longest + "</mark>" + "<mark c=ffc001>" + "次" + "</mark>");
						}
						else if (DWGameManager.getInstance().m_role.m_vip_lv > 0) {
							m_count_text.setText("<mark c=ffc001>" + "VIP"
									+ DWGameManager.getInstance().m_role.m_vip_lv + "玩家，今日还可购买" + "</mark>"
									+ "<mark c=55FF00>" + m_longest + "</mark>"
									+ "<mark c=ffc001>" + "次" + "</mark>");
						}
					}
				}
			}
		});
		m_input.setNearAnchor(m_left_ima, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 15, 0);

		m_right_ima = new DWImageBox(m_cr_right);
		m_right_ima.setNearAnchor(m_input, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 15, 0);
		m_right_ima.setTouchZoomIn(15, 20);
		m_right_ima.addListener(m_right_lis);

		m_must_text = new DWTextbox("需要" + "<mark c=ffc001>" + m_gold + "</mark>");
		m_must_text.setNearAnchor(m_tb, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 10, m_left_ima.getShowHeight() + 30);

		m_yuanbao_ima = new DWImageBox(m_cr_yunbao);
		m_yuanbao_ima.setNearAnchor(m_must_text, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5, 0);

		m_count_text = new DWTextbox("<mark c=ffc001>" + "今日还可购买" + "</mark>" + "<mark c=55FF00>" + m_longest
				+ "</mark>" + "<mark c=ffc001>" + "次" + "</mark>", m_xbj.getShowWidth() - 40);
		m_count_text.setNearAnchor(m_must_text, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, -10, 10);
		if (DWGameManager.getInstance().m_role.m_vip_lv == 0) {
			m_count_text.setText("<mark c=ffc001>" + "非VIP玩家，今日还可购买" + "</mark>" + "<mark c=55FF00>" + m_longest
					+ "</mark>" + "<mark c=ffc001>" + "次" + "</mark>");
		}
		else if (DWGameManager.getInstance().m_role.m_vip_lv > 0) {
			m_count_text.setText("<mark c=ffc001>" + "VIP" + DWGameManager.getInstance().m_role.m_vip_lv + "玩家，今日还可购买"
					+ "</mark>" + "<mark c=55FF00>" + m_longest + "</mark>" + "<mark c=ffc001>"
					+ "次" + "</mark>");
		}
		m_add_but = new DWButton("确定", m_cr_but_richang);
		m_add_but.setDownImage(m_cr_but_richang_anxia);
		m_add_but.setNearAnchor(m_count_text, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, -10, 15);
		m_add_but.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				int m_gold = Integer.parseInt(m_input.getText()) * m_huilv;
				m_count = Byte.parseByte(m_input.getText());
				if (m_gold > DWGameManager.getInstance().m_role.m_rmb) {
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
							"抱歉，您的元宝不足" + m_gold + "，无法购买" + m_count + "次。");
				}
				else {
					if (m_longest == 0) {
						DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "抱歉，您今日的次数已经耗尽。");
					}
					else if (m_longest > 0) {
						if (m_count > 0) {
							DWGameManager.getInstance().getSendMessage().sendAddBuy(m_count);
						}
						else {
							DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
									"抱歉,无法购买0次,操作无效。");
						}
					}
				}
			}
		});

		m_add_frame.addControl(m_tit);
		m_add_frame.addControl(m_tit_ima);
		m_add_frame.addControl(m_tuichu_ima);
		m_add_frame.addControl(m_xbj);
		m_add_frame.addControl(m_tb);
		m_add_frame.addControl(m_left_ima);
		m_add_frame.addControl(m_right_ima);
		m_add_frame.addControl(m_input);
		m_add_frame.addControl(m_must_text);
		m_add_frame.addControl(m_yuanbao_ima);
		m_add_frame.addControl(m_count_text);
		m_add_frame.addControl(m_add_but);
	}

	private DWListener m_left_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_input != null) {
				int m_left_input = Integer.parseInt(m_input.getText());
				if (m_left_input > 0) {
					int m_set_left_input = m_left_input - 1;
					m_input.setText(Integer.toString(m_set_left_input));
					m_must_text.setText("需要" + "<mark c=ffc001>" + m_set_left_input * m_huilv + "</mark>");
					m_yuanbao_ima.setNearAnchor(m_must_text, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5, 0);
				}
				else {
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "当前数量为0，操作无效。");
				}
			}
		}
	};

	private DWListener m_right_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_input != null) {
				int m_right_input = Integer.parseInt(m_input.getText());
				if (m_right_input >= 0 && m_right_input < ((int) m_longest)) {
					int m_set_right_input = m_right_input + 1;
					m_input.setText(Integer.toString(m_set_right_input));
					m_must_text.setText("需要" + "<mark c=ffc001>" + m_set_right_input * m_huilv + "</mark>");
					m_yuanbao_ima.setNearAnchor(m_must_text, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5, 0);
				}
				else {
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "当前数量为今日购买上限，操作无效。");
				}
			}
		}
	};
	private long m_djs_time = 0;

	public void DJS()
	{
		if (DWControlsManager.getInstance().contains(m_assistant_frame)) {
			if (m_activity_list != null) {
				if (m_activity_list.length > 0) {
					for (int m_djs_index = 0; m_djs_index < m_activity_list.length; m_djs_index++) {
						if (m_activity_list[m_djs_index] != null && m_activity_list[m_djs_index].m_count_donw > 0) {
							if (m_djs_time == 0) {
								m_djs_time = System.currentTimeMillis();// 读取时截取系统时间
							}
							long currentTime = System.currentTimeMillis();// 当前系统时间
							int index = (int) (m_activity_list[m_djs_index].m_count_donw - (currentTime - m_djs_time) / 1000);
							// Tools.debugPrintln("坐标："+m_djs_index);
							// Tools.debugPrintln("坐标下的时间："+m_activity_list[m_djs_index].m_count_donw);

							if (index < 0) {
								m_djs_time = 0;
							}
							else {
								if (index == 0) {
									m_activity_list[m_djs_index].m_count_donw = 0;
								}
								if (m_data_text[m_djs_index] != null) {
									m_data_text[m_djs_index].setName("倒计时：" + index);
									m_data_text[m_djs_index].setTextColor(0xFF55FF00);
									if (DWControlsManager.getInstance().contains(
											UIWindows.getInstance().m_jingji.m_count_frame)) {
										m_data_text[m_djs_index].setName(m_activity_list[m_djs_index].m_description);
										m_data_text[m_djs_index].setTextColor(Tools.WHITE);
										m_activity_list[m_djs_index].m_count_donw = 0;
									}
								}
							}
						}
					}
				}
			}
		}
	}

	public void init()
	{
		m_cr_tuichu = UIWindows.createImage("/img/newui/fanhuianniu_1.gnp");
		m_cr_xxbj = UIWindows.createImage("/img/newui/beibaobj_1.gnp");
		m_cr_tit = UIWindows.createImage("/img/newui/zhushou_1.gnp");
		m_cr_tp_1 = UIWindows.createImage("/img/newui/biaoqianye_1.gnp");
		m_cr_tp_2 = UIWindows.createImage("/img/newui/biaoqianye_2.gnp");
		m_cr_grid = UIWindows.createImage("/img/newui/wupinlan.gnp");
		m_cr_but = UIWindows.createImage("/img/newui/anniu_11.gnp");
		m_cr_anxia = UIWindows.createImage("/img/newui/anniu_11ax.gnp");
		m_cr_but_richang = UIWindows.createImage("/img/newui/anniu_6.gnp");
		m_cr_but_richang_anxia = UIWindows.createImage("/img/newui/anniu_6ax.gnp");
		m_cr_tit_add = UIWindows.createImage("/img/newui/jingjizengci_1.gnp");
		m_cr_left = UIWindows.createImage("/img/newui/haoyoufyan_2.gnp");// /个数翻页
		m_cr_right = UIWindows.createImage("/img/newui/haoyoufyan_1.gnp");
		m_cr_yunbao = UIWindows.createImage("/img/newui/yuanbao_1.gnp");

		m_bm_ming = UIWindows.createImage("/img/newui/anniu_14.gnp");
		m_bm_an = UIWindows.createImage("/img/newui/anniu_14ax.gnp");
		m_bm_wancheng = UIWindows.createImage("/img/newui/wancheng_1.gnp");
		m_bm_weiwancheng = UIWindows.createImage("/img/newui/weiwancheng_1.gnp");
		m_bm_foreground = UIWindows.createImage("/img/newui/jindushang_3.gnp");
		m_bm_background = UIWindows.createImage("/img/newui/jinduxia_3.gnp");
		m_bm_huoyue = UIWindows.createImage("/img/newui/huoyuedu_1.gnp");
		//宝箱动画
		Animation chicheng = UIWindows.createAnimation("/anim/baoxiang_1.anim");
		m_donghua_baoxiang = new Actor(chicheng);
		//宝箱图
		m_baoxiang_ming = UIWindows.createImage("/img/newui/zhushoubx_1.gnp");
		m_baoxiang_an = UIWindows.createImage("/img/newui/zhushoubx_2.gnp");
		m_baoxiang_kai = UIWindows.createImage("/img/newui/zhushoubx_3.gnp");
		//底图
		m_bm_ditu = UIWindows.createImage("/img/newui/tiao.gnp");

	}

	public void open(byte index)
	{
		switch (index) {
			case 0:
				Assistant();
				break;
			case 1:
				break;
		}
	}

	public void close(byte index)
	{
	}

	public void dispose()
	{
	}

	public void logic()
	{
		DJS();
	}

	// /////////////////////////////////////////////////////////
	// 通信指令
	// /////////////////////////////////////////////////////////
	public AssEveryday[] m_everyday_list = null;// 日常活动列表
	public AssActivity[] m_activity_list = null;// 定时活动列表
	public AssOperate[] m_operate_list = null;// 运营活动列表

	/**
	 * 读取日常界面信息
	 * 
	 * @param dis
	 */
	public void recvRiChang(DataInputStream dis) throws IOException
	{

	}

	/**
	 * 读取定时信息
	 * 
	 * @param dis
	 * @throws IOException
	 */
	DWTextbox m_simple_tb[]; // /个人竞技场还可参加多少次提醒
	// DWTextbox m_famliy_tb; ///家族竞技场还可参加多少次提醒
	DWTextbox m_miaoshu_other[];//描述2
	public String m_xiuluo_battle_key = null;

	public void recvDingShi(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("读取定时活动开始!");
		if (m_activity_list != null) {
			for (int i = 0; i < m_activity_list.length; i++) {
				m_activity_list[i] = null;
			}
			m_activity_list = null;
		}
		byte size = dis.readByte();
		m_activity_list = new AssActivity[size];
		for (byte i = 0; i < size; i++) {
			AssActivity assa = new AssActivity();
			Tools.debugPrintln("读取第" + i + "个定时活动:");
			assa.m_type = dis.readByte();
			Tools.debugPrintln("类型 : " + assa.m_type);
			assa.m_name = dis.readUTF();
			Tools.debugPrintln("名称 : " + assa.m_name);
			assa.m_subtype = dis.readUTF();
			Tools.debugPrintln("子类型 : " + assa.m_subtype);
			assa.m_icon = dis.readShort();
			Tools.debugPrintln("图标 : " + assa.m_icon);
			assa.m_status = dis.readByte();
			Tools.debugPrintln("状态 : " + assa.m_status);
			assa.m_description = dis.readUTF();
			Tools.debugPrintln("描述 : " + assa.m_description);
			assa.m_description_other = dis.readUTF();
			Tools.debugPrintln("描述2 : " + assa.m_description_other);
			m_activity_list[i] = assa;
		}
		open((byte) 0);
		m_tabcontrol.setSelectPage(1);
		if (m_listbox_1 != null) {
			m_listbox_1.removeAllSubItem();
		}
		m_xxbj_bg = new DWBackground[m_activity_list.length];
		m_data_text = new DWLabel[m_activity_list.length];
		m_simple_tb = new DWTextbox[m_activity_list.length];
		m_miaoshu_other = new DWTextbox[m_activity_list.length];
		m_but = new DWButton[m_activity_list.length];
		m_textbox = new DWTextbox[m_activity_list.length];

		for (int m_data_index = 0; m_data_index < m_activity_list.length; m_data_index++) {
			m_xxbj_bg[m_data_index] = new DWBackground(m_cr_xxbj, (m_listbox_1.getShowWidth() - 20) / 2, (m_listbox_1
					.getShowHeight() - 20) / 2);

			IconManger m_icon = new IconManger();
			m_tubiao_ima_2 = new DWImageBox(m_icon.getIcon(m_activity_list[m_data_index].m_icon));
			m_textbox[m_data_index] = new DWTextbox(m_activity_list[m_data_index].m_name);
			m_data_text[m_data_index] = new DWLabel(m_activity_list[m_data_index].m_description);
			m_data_text[m_data_index].setTextColor(Tools.WHITE);
			m_data_text[m_data_index].setBackgroundColor(Tools.ALPHA);
			m_data_text[m_data_index].setShowWideHigh(m_xxbj_bg[m_data_index].getShowWidth()
					- m_tubiao_ima_2.getShowWidth() - m_cr_but.getWidth() - 30, m_xxbj_bg[m_data_index].getShowHeight()
					- m_textbox[m_data_index].getShowHeight() - 15 - 5);
			m_simple_tb[m_data_index] = new DWTextbox("<mark c=FFBB11>" + "今日还可参加15次" + "</mark>");
			m_miaoshu_other[m_data_index] = new DWTextbox("<mark c=FFBB11>"
					+ m_activity_list[m_data_index].m_description_other + "</mark>");
			switch (DWGameManager.AdpaterType) {
				case DWGameManager.AD_HIGH:
					m_miaoshu_other[m_data_index].setFont(DWFont.getFont(26));
					break;
				default:
					m_miaoshu_other[m_data_index].setFont(DWFont.getFont(16));
					break;
			}
			if (m_activity_list[m_data_index].m_type == 1) {
				DWGameManager.getInstance().getSendMessage().sendAssistantActivityCount();
			}
			m_add_count.setShow(true);
			m_add_count.setTouch(true);
			if (m_activity_list[m_data_index].m_status == 1) {
				m_textbox[m_data_index].setText("<mark c=FFBB11>" + m_activity_list[m_data_index].m_name + "</mark>");
				m_but[m_data_index] = new DWButton("立即参加", m_cr_but);
				m_but[m_data_index].setDownImage(m_cr_anxia);
				final int m_instead_index = m_data_index;
				m_but[m_data_index].addListener(new DWListener() {
					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						UIHook.closeHook();
						DWGameManager.getInstance().m_role.breakAutoAttack();
						if (m_activity_list[m_instead_index].m_type == 1
								|| m_activity_list[m_instead_index].m_type == 2
								|| m_activity_list[m_instead_index].m_type == 5) {
							Jion(m_instead_index, 0, m_activity_list[m_instead_index].m_type);
						}
						else if (m_activity_list[m_instead_index].m_type == 3) {
							final DWMessageBox m_mb = new DWMessageBox("温馨提示", "确定进入"
									+ m_activity_list[m_instead_index].m_name + "？", "确定", "返回");
							DWControlsManager.getInstance().addControl(m_mb);
							m_mb.addListener(new DWListener() {

								public void OnDoubleClick()
								{
								}

								public void OnClick()
								{
									if (m_mb.getResult() == DWMessageBox.SOFTKEY_OK) {
										DWGameManager.getInstance().getSendMessage().sendGameCarbonCheck(
												m_activity_list[m_instead_index].m_subtype);
									}
									else if (m_mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
									}
									DWControlsManager.getInstance().removeControl(m_mb);
								}
							});
						}
						else if (m_activity_list[m_instead_index].m_type == 6) {
							Tools.debugPrintln("发送指令m_role");
							DWGameManager.getInstance().getSendMessage().sendDuelAnswerGetinto(
									DWGameManager.getInstance().m_role.m_gameId);

						}
						else if (m_activity_list[m_instead_index].m_type == 7) {
							DWGameManager.getInstance().getSendMessage().sendScenePathfinding(
									m_activity_list[m_instead_index].m_subtype);
							if (DWControlsManager.getInstance().contains(m_assistant_frame)) {
								if (m_assistant_frame != null) {
									DWControlsManager.getInstance().removeControl(m_assistant_frame);
								}
							}
						}
						else if (m_activity_list[m_instead_index].m_type == 8) {
							// m_xiuluo_battle_key =
							// m_activity_list[m_instead_index].m_subtype;
							DWGameManager.getInstance().getSendMessage().sendScenePathfinding(
									m_activity_list[m_instead_index].m_subtype);
							if (DWControlsManager.getInstance().contains(m_assistant_frame)) {
								if (m_assistant_frame != null) {
									DWControlsManager.getInstance().removeControl(m_assistant_frame);
								}
							}
						}
					}
				});
			}
			else if (m_activity_list[m_data_index].m_status == 0) {
				m_but[m_data_index] = new DWButton("未开启", m_cr_anxia);
			}
			m_tubiao_ima_2.setNearAnchor(m_xxbj_bg[m_data_index], Tools.LEFT_VCENTER, Tools.LEFT_VCENTER, 10, 0);
			m_textbox[m_data_index].setNearAnchor(m_xxbj_bg[m_data_index], Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0, 0);
			m_data_text[m_data_index].setNearAnchor(m_xxbj_bg[m_data_index], Tools.LEFT_TOP, Tools.LEFT_TOP,
					10 + 10 + m_tubiao_ima_2.getShowWidth(), m_textbox[m_data_index].getShowHeight() + 10);
			m_but[m_data_index].setNearAnchor(m_xxbj_bg[m_data_index], Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, -5, 0);
			m_simple_tb[m_data_index].setNearAnchor(m_xxbj_bg[m_data_index], Tools.HCENTER_BOTTOM,
					Tools.HCENTER_BOTTOM, 0, 0);
			m_miaoshu_other[m_data_index].setNearAnchor(m_xxbj_bg[m_data_index], Tools.HCENTER_BOTTOM,
					Tools.HCENTER_BOTTOM, 0, 0);
			if (m_data_index % 2 == 0) {
				m_lsi = new DWListSubItem();

				m_xxbj_bg[m_data_index].setNearAnchor(m_lsi, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				m_lsi.addControls(m_xxbj_bg[m_data_index]);
				m_lsi.addControls(m_tubiao_ima_2);
				m_lsi.addControls(m_textbox[m_data_index]);
				m_lsi.addControls(m_data_text[m_data_index]);
				m_lsi.addControls(m_but[m_data_index]);
				m_lsi.addControls(m_simple_tb[m_data_index]);
				m_lsi.addControls(m_miaoshu_other[m_data_index]);
				m_simple_tb[m_data_index].setShow(false);
				if (m_data_index == m_activity_list.length - 1) {
					m_listbox_1.addSubItem(m_lsi);
				}
			}
			else {
				m_xxbj_bg[m_data_index].setNearAnchor(m_xxbj_bg[m_data_index - 1], Tools.LEFT_TOP, Tools.RIGHT_TOP, 20,
						0);
				m_lsi.addControls(m_xxbj_bg[m_data_index]);
				m_lsi.addControls(m_tubiao_ima_2);
				m_lsi.addControls(m_textbox[m_data_index]);
				m_lsi.addControls(m_data_text[m_data_index]);
				m_lsi.addControls(m_but[m_data_index]);
				m_lsi.addControls(m_simple_tb[m_data_index]);
				m_lsi.addControls(m_miaoshu_other[m_data_index]);
				m_simple_tb[m_data_index].setShow(false);
				m_listbox_1.addSubItem(m_lsi);
			}
		}
		if (!m_yunying_flag) {
			if (!Login.m_icon_flag_1) {
				m_listbox_1.setScrollbar(m_assistant_index_1 / 2);
				Tools.debugPrintln("定时全服闪的滚动条：" + m_assistant_index_1 / 2);
			}
			else {
				if (!Login.m_icon_more_flag_1) {
					m_listbox_1.setScrollbar(m_assistant_index_1 / 2);
					Tools.debugPrintln("定时滚动条：" + m_assistant_index_1 / 2);
				}
				else {
					m_listbox_1.setScrollbar(0);
				}
			}
			m_yunying_flag = true;
			Login.m_icon_flag_1 = true;
			Login.m_icon_more_flag_1 = true;
		}
		else if (m_yunying_flag) {
			m_listbox_1.setScrollbar(0);
		}
		Tools.debugPrintln("读取定时活动成功!");
	}

	/**
	 * 读取运营信息
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvYunYing(DataInputStream dis) throws IOException
	{

	}

	/**
	 * 读取主界面更新助手图标
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public byte m_assistant_type = 0; // 类型
	public short m_assistant_icon;// 图标icon
	public byte m_assistant_index = 0;// 开启的活动的下标

	public void recvUpdateIcon(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("全服的闪更新主界面助手图标!");
		m_assistant_type = dis.readByte();
		m_assistant_icon = dis.readShort();
		m_assistant_index = dis.readByte();

		if (m_assistant_type == 0) {
			m_assistant_type_0 = m_assistant_type;
			m_assistant_icon_0 = m_assistant_icon;
			m_assistant_index_0 = m_assistant_index;
			Tools.debugPrintln("类型：" + m_assistant_type + ";图标：" + m_assistant_icon_0 + ";第" + m_assistant_index_0
					+ "个");
		}
		else if (m_assistant_type == 1) {
			m_assistant_type_1 = m_assistant_type;
			m_assistant_icon_1 = m_assistant_icon;
			m_assistant_index_1 = m_assistant_index;
			Login.m_icon_flag_1 = false;
			m_icon_flag_1 = Boolean_Icon(m_assistant_icon_1, m_icon_flag_1);
			Tools.debugPrintln("类型：" + m_assistant_type + ";图标：" + m_assistant_icon_1 + ";第" + m_assistant_index_1
					+ "个");
			Tools.debugPrintln("m_icon_flag_1:" + m_icon_flag_1);
		}
		else {
			m_assistant_type_2 = m_assistant_type;
			m_assistant_icon_2 = m_assistant_icon;
			m_assistant_index_2 = m_assistant_index;
			Login.m_icon_flag_2 = false;
			m_icon_flag_2 = Boolean_Icon(m_assistant_icon_2, m_icon_flag_2);
			Tools.debugPrintln("类型：" + m_assistant_type + ";图标：" + m_assistant_icon_2 + ";第" + m_assistant_index_2
					+ "个");
			Tools.debugPrintln("m_icon_flag_2:" + m_icon_flag_2);
		}
		IconMore();
	}

	/**
	 * 根据icon，boolean变量返回boolea变量值
	 * @param icon
	 * @param flag
	 * @return
	 */
	public boolean Boolean_Icon(short icon, boolean flag)
	{
		if (icon == 0)
		{
			flag = false;
			Tools.debugPrintln("icon:" + icon + ";flag:" + flag);
		}
		else if (icon != 0)
		{
			flag = true;
			Tools.debugPrintln("icon:" + icon + ";flag:" + flag);
		}
		return flag;
	}

	public void recvUpdateIconMore(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("玩家自己的闪更新主界面助手图标!");
		m_assistant_type = dis.readByte();
		m_assistant_icon = dis.readShort();
		m_assistant_index = dis.readByte();

		if (m_assistant_type == 0) {
			m_assistant_type_0 = m_assistant_type;
			m_assistant_icon_0 = m_assistant_icon;
			m_assistant_index_0 = m_assistant_index;
			Tools.debugPrintln("类型：" + m_assistant_type + ";图标：" + m_assistant_icon_0 + ";第" + m_assistant_index_0
					+ "个");
		}
		else if (m_assistant_type == 1) {
			m_assistant_type_1 = m_assistant_type;
			m_assistant_icon_1 = m_assistant_icon;
			m_assistant_index_1 = m_assistant_index;
			Login.m_icon_more_flag_1 = false;
			m_icon_flag_1 = Boolean_Icon(m_assistant_icon_1, m_icon_flag_1);
			Tools.debugPrintln("类型：" + m_assistant_type + ";图标：" + m_assistant_icon_1 + ";第" + m_assistant_index_1
					+ "个");
			Tools.debugPrintln("m_icon_flag_1:" + m_icon_flag_1);
		}
		else {
			m_assistant_type_2 = m_assistant_type;
			m_assistant_icon_2 = m_assistant_icon;
			m_assistant_index_2 = m_assistant_index;
			Login.m_icon_more_flag_2 = false;
			m_icon_flag_2 = Boolean_Icon(m_assistant_icon_2, m_icon_flag_2);
			Tools.debugPrintln("类型：" + m_assistant_type + ";图标：" + m_assistant_icon_2 + ";第" + m_assistant_index_2
					+ "个");
			Tools.debugPrintln("m_icon_flag_2:" + m_icon_flag_2);
		}
		IconMore();
	}

	/**
	 * 定时、运营活动的图片是否显示及是否是闪烁的状态
	 * @param iocn
	 * @param i
	 */
	public void Icon_Select(short iocn, int i)
	{

		if (i == 0)
		{
			UIWindows.getInstance().m_main.m_imageBox_yunying.setShow(false);
			UIWindows.getInstance().m_main.m_imageBox_yunying.setTouch(false);
			UIWindows.getInstance().m_main.m_imageBox_banjiang.
					setNearAnchor(UIWindows.getInstance().m_main.m_imageBox_yunying, Tools.LEFT_VCENTER,
							Tools.RIGHT_VCENTER, -48, 0);
			UIWindows.getInstance().m_main.m_imageBox_yunying.setSelect(false);
		}
		else if (i == 1)
		{
			UIWindows.getInstance().m_main.m_imageBox_yunying.setImage(IconManger.getInstance().getIcon(iocn));
			UIWindows.getInstance().m_main.m_imageBox_yunying.setShow(true);
			UIWindows.getInstance().m_main.m_imageBox_yunying.setTouch(true);
			UIWindows.getInstance().m_main.m_imageBox_banjiang.
					setNearAnchor(UIWindows.getInstance().m_main.m_imageBox_yunying, Tools.LEFT_VCENTER,
							Tools.RIGHT_VCENTER, 10, 0);
			UIWindows.getInstance().m_main.m_imageBox_yunying.setSelect(true);
			UIWindows.getInstance().m_main.m_imageBox_yunying.setSelectType(DWImageBox.SELECT_TYPE_ARC3);
		}
	}

	/**
	 * 定时运营活动的图片显示
	 */
	public void IconMore()
	{
		if (UIWindows.getInstance().m_main.m_Uimain_Frame != null
				&& DWControlsManager.getInstance().contains(UIWindows.getInstance().m_main.m_Uimain_Frame)) {
			// 日常活动的图标
			if (m_assistant_type == 0)
			{
				if (m_assistant_icon_0 == -1) {
					UIWindows.getInstance().m_main.m_imageBox_huodong.setSelect(true);
					UIWindows.getInstance().m_main.m_imageBox_huodong.setSelectType(DWImageBox.SELECT_TYPE_ARC3);
				}
				else {
					UIWindows.getInstance().m_main.m_imageBox_huodong.setSelect(false);
				}
			}
			else
			{
				// /定时活动的图标和运营活动图标
				if (m_icon_flag_1 && m_icon_flag_2)
				{
					m_instead_icon = m_assistant_icon;
					Icon_Select(m_assistant_icon, 1);
				}
				else if (!m_icon_flag_1 && m_icon_flag_2)
				{
					Icon_Select(m_assistant_icon_2, 1);
				}
				else if (m_icon_flag_1 && !m_icon_flag_2)
				{
					Icon_Select(m_assistant_icon_1, 1);
				}
				else if (!m_icon_flag_1 && !m_icon_flag_2)
				{
					Icon_Select((short) 0, 0);
				}
			}
		}
		else {
			return;
		}
	}

	/**
	 * 运营定时活动的按钮监听
	 */
	public DWListener m_yunying_listener = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (DWGameManager.getInstance().m_role.isSellStatus()) {
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "摆摊中，无法操作！");
				return;
			}
			m_yunying_flag = false;
			if (m_icon_flag_1 && m_icon_flag_2)
			{
				if (m_instead_icon == m_assistant_icon_1)
				{
					m_icon_flag_1 = false;
					Icon_Select(m_assistant_icon_2, 1);
					DWGameManager.getInstance().getSendMessage().sendAssistantActivityOpen();
				}
				else if (m_instead_icon == m_assistant_icon_2)
				{
					m_icon_flag_2 = false;
					Icon_Select(m_assistant_icon_1, 1);
					DWGameManager.getInstance().getSendMessage().sendAssistantOperateOpen();
				}
			}
			else if (!m_icon_flag_1 && m_icon_flag_2)
			{
				m_icon_flag_2 = false;
				Icon_Select((short) 0, 0);
				DWGameManager.getInstance().getSendMessage().sendAssistantOperateOpen();
			}
			else if (m_icon_flag_1 && !m_icon_flag_2)
			{
				m_icon_flag_1 = false;
				Icon_Select((short) 0, 0);
				DWGameManager.getInstance().getSendMessage().sendAssistantActivityOpen();
			}
			else if (!m_icon_flag_1 && !m_icon_flag_2)
			{
				Icon_Select((short) 0, 0);
			}
		}
	};
	/**
	 * 读取定时活动排队成功
	 * 
	 * @param dis
	 * @throws IOException
	 */
	byte m_type;
	String m_subtype;
	int m_index;

	public void recvActivityLineup(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("定时活动排队成功!");
		byte type = dis.readByte();
		Tools.debugPrintln("类型 : " + type);
		int time = dis.readInt();
		Tools.debugPrintln("倒计时 : " + time);
		String subType = dis.readUTF();
		Tools.debugPrintln("子类型 : " + subType);

		m_type = type;
		m_subtype = subType;
		m_djs_time = System.currentTimeMillis();
		for (int i = 0; i < m_activity_list.length; i++) {
			if (m_activity_list[i].m_type == m_type && m_activity_list[i].m_subtype.equals(m_subtype)) {
				m_activity_list[i].m_count_donw = time;
				m_but[i].setName("取消报名");
				m_index = i;
				Tools.debugPrintln("i:" + i);
				m_data_text[i].setName("倒计时：" + time);
				m_data_text[i].setTextColor(0xFF55FF00);
				m_data_text[i].setDefaultNearAnchorUn();
				m_tp[1].refreshControl();
				DWGameManager.getInstance().getSendMessage().sendAssistantActivityCount();
				break;
			}
		}
	}

	/**
	 * 读取定时活动取消排队
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvActivityQuit(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("定时活动取消排队!");
		byte type = dis.readByte();
		Tools.debugPrintln("类型 : " + type);
		String description = dis.readUTF();
		Tools.debugPrintln("描述 : " + description);
		String subType = dis.readUTF();
		Tools.debugPrintln("子类型 : " + subType);

		for (int i = 0; i < m_activity_list.length; i++) {
			if (m_activity_list[i].m_type == type && m_activity_list[i].m_subtype.equals(subType)) {
				m_data_text[i].setName(description);
				m_data_text[i].setTextColor(Tools.WHITE);
				m_data_text[i].setDefaultNearAnchorUn();
				m_activity_list[i].m_count_donw = 0;
				m_but[i].setName("立即参加");
				m_tp[1].refreshControl();
				break;
			}
		}
	}

	/**
	 * 读取还可参加活动的次数
	 */
	public void recvActivityCount(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("定时活动还可参加次数!");
		// byte type = dis.readByte();
		// Tools.debugPrintln("类型 : " + type);
		byte count = dis.readByte();
		Tools.debugPrintln("还可参加次数 : " + count);

		// if(type == 1)
		// {
		if (DWControlsManager.getInstance().contains(m_assistant_frame)) {
			for (int i = 0; i < m_activity_list.length; i++) {
				if (m_activity_list[i].m_type == 1) {
					m_simple_tb[i].setText("<mark c=FFBB11>" + "今日还可参加" + count + "次" + "</mark>");
					m_simple_tb[i].setShow(true);
					return;
				}
			}
		}
		// }
		// else if(type == 2)
		// {
		// m_famliy_tb.setText("<mark c=FFBB11>"+"今日还可参加"+count+"次"+"</mark>");
		// }
	}

	/**
	 * 读取日常活动列表
	 * 
	 * @param dis
	 * @throws IOException
	 */
	DWListSubItem m_subitem[];//日常活动subitem
	DWTextbox[] m_text_richang_list;
	byte m_richang_size;//日常活动个数

	public void recvEverydayList(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("读取日常活动列表开始!");
		if (m_everyday_list != null) {
			int len = m_everyday_list.length;
			for (int i = 0; i < len; i++) {
				m_everyday_list[i] = null;
			}
			m_everyday_list = null;
		}

		m_richang_size = dis.readByte();//任务个数
		m_everyday_list = new AssEveryday[m_richang_size];
		for (int i = 0; i < m_richang_size; i++) {
			AssEveryday everyday = new AssEveryday();
			everyday.m_name = dis.readUTF();//name
			everyday.m_index = dis.readInt();//标志这个任务
			everyday.m_plan = dis.readUTF();//完成次数(拼好的)
			everyday.m_reward = dis.readUTF();//奖励
			everyday.m_huoyuedu = dis.readInt();//活跃度
			everyday.m_type = dis.readByte();//类型
			everyday.m_state = dis.readByte();//状态
			everyday.m_type_key = dis.readUTF();//类型key
			if (everyday.m_type == AssEveryday.TYPE_OPEN) {
				everyday.m_type_subkey = dis.readUTF();//类型二级key
			}
			m_everyday_list[i] = everyday;
		}

		m_bar_nowNum = dis.readInt();//当前值
		m_bar_total = dis.readInt();//总值
		m_baoxiang_num = dis.readByte();//礼包个数
		m_libao_zhi = new int[m_baoxiang_num];//各个礼包位置的数值
		m_libao_zhuangtai = new byte[m_baoxiang_num];//礼包的状态
		m_libao_jiangli = new String[m_baoxiang_num];
		m_libao_biaozhi = new int[m_baoxiang_num];
		for (int i = 0; i < m_baoxiang_num; i++) {
			m_libao_biaozhi[i] = dis.readInt();
			m_libao_zhi[i] = dis.readInt();
			m_libao_zhuangtai[i] = dis.readByte();
			m_libao_jiangli[i] = dis.readUTF();
		}
		m_richang_count = dis.readByte();

		UIWindows.getInstance().m_main.m_imageBox_huodong.setSelect(false);
		open((byte) 0);
		m_tabcontrol.setSelectPage(0);

		//刷新listBox中的内容
		refreshListBox();
		refreshBar();
	}

	public void Everyday(int index)
	{
		m_text_richang.setText("功能规则：" + m_everyday_list[index].m_describe + DWControlTools.CHANGE_ROW
				+ DWControlTools.CHANGE_ROW + "功能奖励：" + m_everyday_list[index].m_reward
				+ DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "参与条件：" + m_everyday_list[index].m_restrict);
		if (m_everyday_list[index].m_state == 0) {
			m_but_richang.setBackground(m_cr_but_richang_anxia, true);
			m_but_richang.setTouch(false);
		}
		else if (m_everyday_list[index].m_state == 1) {
			m_but_richang.setBackground(m_cr_but_richang, true);
			m_but_richang.setDownImage(m_cr_but_richang_anxia);
			m_but_richang.setTouch(true);
		}
	}

	public void Oper(int index)
	{
		m_text_yunying.setText("功能规则：" + m_operate_list[index].m_description + DWControlTools.CHANGE_ROW
				+ DWControlTools.CHANGE_ROW + "参与条件：" + m_operate_list[index].m_condition);
		if (m_operate_list[index].m_state == 0) {
			m_but_yunying.setBackground(m_cr_but_richang_anxia, true);
			m_but_yunying.setTouch(false);
		}
		else if (m_operate_list[index].m_state == 1) {
			m_but_yunying.setBackground(m_cr_but_richang, true);
			m_but_yunying.setDownImage(m_cr_but_richang_anxia);
			m_but_yunying.setTouch(true);
		}
	}

	/**
	 * 添加日常活动
	 * 
	 * @param dis
	 * @throws IOException
	 */
	AssEveryday everyday;

	public void recvEverydayAdd(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("添加日常活动开始!");
		everyday = new AssEveryday();
		everyday.m_name = dis.readUTF();
		Tools.debugPrintln("名字 : " + everyday.m_name);
		everyday.m_key = dis.readUTF();
		Tools.debugPrintln("key : " + everyday.m_key);
		everyday.m_describe = dis.readUTF();
		Tools.debugPrintln("描述 : " + everyday.m_describe);
		everyday.m_reward = dis.readUTF();
		Tools.debugPrintln("奖励 : " + everyday.m_reward);
		everyday.m_restrict = dis.readUTF();
		Tools.debugPrintln("限制 : " + everyday.m_restrict);
		everyday.m_type = dis.readByte();
		Tools.debugPrintln("类型 : " + everyday.m_type);
		everyday.m_type_key = dis.readUTF();
		Tools.debugPrintln("类型key : " + everyday.m_type_key);
		if (everyday.m_type == AssEveryday.TYPE_OPEN) {
			everyday.m_type_subkey = dis.readUTF();
			Tools.debugPrintln("类型二级key : " + everyday.m_type_subkey);
		}
		if (m_everyday_list != null) {
			AssEveryday[] newEveryday = new AssEveryday[m_everyday_list.length + 1];
			System.arraycopy(m_everyday_list, 0, newEveryday, 0, m_everyday_list.length);
			newEveryday[newEveryday.length - 1] = everyday;
			m_everyday_list = newEveryday;
		}
		Tools.debugPrintln("读取日常活动详细信息结束!");

		DWListSubItem m_sub = new DWListSubItem();
		m_sub.setNearAnchor(m_subitem[m_richang_size - 1], Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 10);
		DWTextbox m_tb = new DWTextbox(everyday.m_name, m_listbox_0.getShowWidth());
		m_tb.setNearAnchor(m_sub, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
		m_sub.addControls(m_tb);
		m_listbox_0.addSubItem(m_sub);
		m_tb.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				m_text_richang.setText("功能规则：" + everyday.m_describe + DWControlTools.CHANGE_ROW
						+ DWControlTools.CHANGE_ROW + "功能奖励：" + everyday.m_reward + DWControlTools.CHANGE_ROW
						+ DWControlTools.CHANGE_ROW + "参与条件：" + everyday.m_restrict);
			}
		});
	}

	/** 打开运营界面 */
	DWListSubItem m_yunying_subitem[];
	DWTextbox m_yunying_list[];

	public void recvOperateList(DataInputStream dis) throws IOException
	{
		try {
			byte size = dis.readByte();
			if (size <= 0) {
				if (m_listbox_2 != null) {
					m_listbox_2.removeAllSubItem();
				}
				if (m_assistant_frame.contains(m_text_yunying)) {
					m_text_yunying.setText("");
				}
				if (m_assistant_frame.contains(m_but_yunying)) {
					m_but_yunying.setShow(false);
					m_but_yunying.setTouch(false);
				}
				return;
			}
			m_operate_list = null;
			m_operate_list = new AssOperate[size];
			AssOperate obj = null;
			for (int i = 0; i < size; i++) {
				obj = new AssOperate();
				obj.m_state = dis.readByte();
				obj.m_title = dis.readUTF();
				obj.m_key = dis.readUTF();
				obj.m_description = dis.readUTF();
				obj.m_condition = dis.readUTF();
				obj.m_funcType = dis.readByte();
				Tools.debugPrintln("第" + i + "个运营活动：");
				Tools.debugPrintln("state:" + obj.m_state);
				Tools.debugPrintln("m_title:" + obj.m_title);
				Tools.debugPrintln("m_key:" + obj.m_key);
				Tools.debugPrintln("m_description" + obj.m_description);
				Tools.debugPrintln("m_condition:" + obj.m_condition);
				Tools.debugPrintln("m_funcType:" + obj.m_funcType);
				switch (obj.m_funcType) {
					case 0:
						obj.m_parameter = new String[2];
						obj.m_parameter[0] = dis.readUTF();
						obj.m_parameter[1] = dis.readUTF();
						break;
					default:
						obj.m_parameter = new String[1];
						obj.m_parameter[0] = dis.readUTF();
						break;
				}
				m_operate_list[i] = obj;
				obj = null;
			}
			open((byte) 0);
			m_tabcontrol.setSelectPage(2);
			if (m_listbox_2 != null) {
				m_listbox_2.removeAllSubItem();
			}
			m_yunying_subitem = new DWListSubItem[size];
			m_yunying_list = new DWTextbox[size];
			for (int i = 0; i < size; i++) {
				m_yunying_subitem[i] = new DWListSubItem();
				m_yunying_list[i] = new DWTextbox(m_operate_list[i].m_title, m_listbox_2.getShowWidth());
				m_yunying_list[i].setNearAnchor(m_yunying_subitem[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				final int m_index_richang = i;
				m_yunying_list[i].addListener(new DWListener() {

					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						Oper(m_index_richang);
					}
				});
				m_yunying_subitem[i].addControls(m_yunying_list[i]);
				m_listbox_2.addSubItem(m_yunying_subitem[i]);
			}
			if (!m_yunying_flag) {
				if (!Login.m_icon_flag_2) {
					m_listbox_2.setTouchIndex(m_assistant_index_2);
					m_text_yunying.setText("功能规则：" + m_operate_list[m_assistant_index_2].m_description
							+ DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "参与条件："
							+ m_operate_list[m_assistant_index_2].m_condition);
					if (m_operate_list[m_assistant_index_2].m_state == 0) {
						m_but_yunying.setShow(true);
						m_but_yunying.setBackground(m_cr_but_richang_anxia, false);
						m_but_yunying.setTouch(false);
					}
					else if (m_operate_list[m_assistant_index_2].m_state == 1) {
						m_but_yunying.setShow(true);
						m_but_yunying.setBackground(m_cr_but_richang, false);
						m_but_yunying.setDownImage(m_cr_but_richang_anxia);
						m_but_yunying.setTouch(true);
					}
				}
				else {
					if (!Login.m_icon_more_flag_2) {
						m_listbox_2.setTouchIndex(m_assistant_index_2);
						m_text_yunying.setText("功能规则：" + m_operate_list[m_assistant_index_2].m_description
								+ DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "参与条件："
								+ m_operate_list[m_assistant_index_2].m_condition);
						if (m_operate_list[m_assistant_index_2].m_state == 0) {
							m_but_yunying.setShow(true);
							m_but_yunying.setBackground(m_cr_but_richang_anxia, false);
							m_but_yunying.setTouch(false);
						}
						else if (m_operate_list[m_assistant_index_2].m_state == 1) {
							m_but_yunying.setShow(true);
							m_but_yunying.setBackground(m_cr_but_richang, false);
							m_but_yunying.setDownImage(m_cr_but_richang_anxia);
							m_but_yunying.setTouch(true);
						}
					}
					else {
						m_listbox_2.setTouchIndex(0);
						m_text_yunying.setText("功能规则：" + m_operate_list[0].m_description + DWControlTools.CHANGE_ROW
								+ DWControlTools.CHANGE_ROW + "参与条件：" + m_operate_list[0].m_condition);
						if (m_operate_list[0].m_state == 0) {
							m_but_yunying.setShow(true);
							m_but_yunying.setBackground(m_cr_but_richang_anxia, false);
							m_but_yunying.setTouch(false);
						}
						else if (m_operate_list[0].m_state == 1) {
							m_but_yunying.setBackground(m_cr_but_richang, false);
							m_but_yunying.setDownImage(m_cr_but_richang_anxia);
							m_but_yunying.setShow(true);
							m_but_yunying.setTouch(true);
						}
					}
				}
				if (!Login.m_icon_flag_2) {
					m_listbox_2.setScrollbar(m_assistant_index_2);
					Tools.debugPrintln("运营全服闪的滚动条：" + m_assistant_index_2);
				}
				else {
					if (!Login.m_icon_more_flag_2) {
						m_listbox_2.setScrollbar(m_assistant_index_2);
						Tools.debugPrintln("运营滚动条：" + m_assistant_index_2);
					}
					else {
						m_listbox_2.setScrollbar(0);
					}
				}
				Login.m_icon_flag_2 = true;
				Login.m_icon_more_flag_2 = true;
				m_yunying_flag = true;
			}
			else if (m_yunying_flag) {
				m_listbox_2.setTouchIndex(0);
				m_text_yunying.setText("功能规则：" + m_operate_list[0].m_description + DWControlTools.CHANGE_ROW
						+ DWControlTools.CHANGE_ROW + "参与条件：" + m_operate_list[0].m_condition);
				if (m_operate_list[0].m_state == 0) {
					m_but_yunying.setShow(true);
					m_but_yunying.setBackground(m_cr_but_richang_anxia, false);
					m_but_yunying.setTouch(false);
				}
				else if (m_operate_list[0].m_state == 1) {
					m_but_yunying.setBackground(m_cr_but_richang, false);
					m_but_yunying.setDownImage(m_cr_but_richang_anxia);
					m_but_yunying.setShow(true);
					m_but_yunying.setTouch(true);
				}
				m_listbox_2.setScrollbar(0);
			}
		}
		catch (Exception e) {
			Tools.debug(e);
		}
	}

	byte m_type_instead = 0;

	public void Jion(int i, int index, byte m_type)
	{
		switch (index) {
			case 0:
				if (m_but[i].getName().equals("立即参加")) {
					DWGameManager.getInstance().getSendMessage().sendARENAJOIN(m_type);
				}
				else if (m_but[i].getName().equals("取消报名")) {
					// ///取消报名的指令
					final DWMessageBox m_mb = new DWMessageBox("温馨提示", "确定取消" + m_activity_list[i].m_name + "的报名？",
							"确定", "返回");
					m_type_instead = m_type;
					m_mb.addListener(new DWListener() {

						public void OnDoubleClick()
						{
						}

						public void OnClick()
						{
							if (m_mb.getResult() == DWMessageBox.SOFTKEY_OK) {
								DWGameManager.getInstance().getSendMessage().sendARENAcancel(m_type_instead);
								DWControlsManager.getInstance().removeControl(m_mb);
							}
							else if (m_mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
								DWControlsManager.getInstance().removeControl(m_mb);
							}
						}
					});
					DWControlsManager.getInstance().addControl(m_mb);
				}
				break;
		}
	}

}
